home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / tsr.swg / 0007_Remove TSR.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-05-28  |  3.7 KB  |  144 lines

  1. {ok i would like some info on how to remove a tsr
  2.  
  3. Follow these steps:
  4.  
  5.    I tested out some TSR code today and came up With this. It's been
  6.    debugged and Functions as advertised. not as clean as I'd like,
  7.    but it works.
  8. }
  9.  
  10. {**********************************************
  11.  * CLICK.PAS by Larry Hadley  2-02-1993       *
  12.  * donated to the public domain. if you use   *
  13.  * this code or derive from it, credit would  *
  14.  * be appreciated.                            *
  15.  ********************************************** }
  16.  
  17. {$S-,N-}
  18. {$M 1024, 0, 0}
  19. Program CLICK;
  20.  
  21. Uses
  22.   Crt,Dos;
  23.  
  24. Var
  25.   SavedInt09h,
  26.   SavedInt66h  :Pointer;
  27.  
  28. Procedure keyClick;
  29. begin
  30.   Sound(50);
  31.   Delay(1);
  32.   NoSound;
  33. end;
  34.  
  35. Procedure Int09h; interrupt;
  36. begin
  37.   keyClick;           { Sound click everytime called -
  38.                         this is clumsy because key releases as
  39.                         well as keypresses are signalled. Good
  40.                         thing this is For demo only! :-) }
  41.   Asm
  42.     pushf            { push flags to simulate "int" call }
  43.     call SavedInt09h { pass control to original int09 handler -
  44.                        necessary to allow keyboard use. Also
  45.                        demo's chaining of interrupts. }
  46.   end;
  47. end;
  48.  
  49. Procedure Int66h(AX, BX, CX, DX, SI, DI, DS, ES, BP:Word); interrupt;
  50. Var
  51.   int09new :Pointer;
  52. begin
  53.   if AX<>$FFFF then
  54.     Exit;            { not our call, leave }
  55.  
  56.   GetIntVec($09, int09new);
  57.   if int09new<>@int09h then
  58.     Exit;            { interrupt vectors have been changed. }
  59.  
  60.   SetIntVec($09, SavedInt09h); { restore interrupt vectors }
  61.   SetIntVec($66, SavedInt66h);
  62.  
  63.   MemW[PrefixSeg:$16] := BX; { modify PSP to return to calling }
  64.   MemW[PrefixSeg:$0A] := DI; { Program... }
  65.   MemW[PrefixSeg:$0C] := ES;
  66.  
  67.   Asm
  68.     mov ah, $50
  69.     mov bx, PrefixSeg
  70.     push ds
  71.     int $21            { set conText }
  72.     pop ds
  73.   end;
  74.   AX := 0;        { tell caller "no error" }
  75. end;
  76.  
  77. begin   { main - t.s.r. init code }
  78.   GetIntVec($09, SavedInt09h);
  79.   GetIntVec($66, SavedInt66h);
  80.  
  81.   SetIntVec($09, #Int09h);
  82.   SetIntVec($66, @Int66h);
  83.  
  84.   Writeln('Click TSR installed.');
  85.  
  86.   Keep(0);
  87. end.
  88.  
  89. {************************************************
  90.  * CLICKU.PAS by Larry Hadley  2-02-1993        *
  91.  * CLICK T.S.R. removal Program                 *
  92.  * released into the public domain. if you use  *
  93.  * this code or derive from it, credit would be *
  94.  * appreciated.                                 *
  95.  ************************************************}
  96.  
  97. {$S-,N-}
  98. Program CLICKU;
  99.  
  100. Uses
  101.   Dos;
  102.  
  103. Var
  104.   rtn_seg,
  105.   rtn_ofs  : Word;
  106.   return   : Pointer;
  107.  
  108. Label int66_error;
  109.  
  110. Procedure Exit_Label; { ...to provide an address For Dos return to }
  111. begin
  112.   Halt(0);  { I haven't been able to establish For sure that
  113.               this code regains control here. BTW, Brian I have
  114.               code to save DS and restore upon return to this
  115.               Program if you're interested.  This would allow
  116.               using global Variables to save SS:SP. Int 21h func
  117.               $4C destroys DS (and just about everything else)
  118.               on Exit...}
  119. end;
  120.  
  121. begin
  122.   return := @exit_Label;
  123.   rtn_seg := SEG(return^);
  124.   rtn_ofs := ofS(return^);
  125.   Asm
  126.     mov ax, $FFFF
  127.     mov bx, PrefixSeg
  128.     mov es, rtn_seg
  129.     mov di, rtn_ofs      { pass parms in Registers ax, bx, es, di}
  130.     int $66              { call i.s.r. uninstall Function }
  131.     cmp ax, 0
  132.     jne int66_error      { i.s.r. has returned error }
  133.   end;
  134.   Writeln('Click TSR uninstalled.');
  135.   Asm
  136.     mov ah, $4C
  137.     int $21              { Dos terminate }
  138.   end;
  139.  
  140.   int66_error:
  141.   Writeln('Error removing TSR.');
  142.   Halt(1);
  143. end.
  144.